package mobi.richaze.llbag.infrastructure.hibernate;

import java.util.List;

import mobi.richaze.llbag.domain.model.order.LineItem;
import mobi.richaze.llbag.domain.model.product.Inventory;
import mobi.richaze.llbag.domain.model.product.Item;
import mobi.richaze.llbag.domain.model.product.Product;
import mobi.richaze.llbag.domain.model.product.ProductRepository;

import org.hibernate.Criteria;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

@Repository("ProductRepositoryHibernate")
public class ProductRepositoryHibernate extends HibernateRepository<Product>
		implements ProductRepository {
	private static final Logger log = LoggerFactory
			.getLogger(AccountRepositoryHibernate.class);

	@SuppressWarnings("unchecked")
	public List<Inventory> getInventory() {
		log.debug("getting Inventory instances");
		List<Inventory> list = null;
		try {
			// System.out.println("========"+getHibernateTemplate());
			// Inventory account = getHibernateTemplate().get(Inventory.class,
			// "1");
			// System.out.println(":::::" + account.getQty());
			Criteria criteria = getSession().createCriteria(Inventory.class,
					"scheme");
			list = criteria.list();
			log.debug("get Account instances successful, result size: "
					+ list.size());
		} catch (Exception ex) {
			log.error("get failed", ex);
			ex.printStackTrace();
		}

		return list;
	}

	public List<Product> getProductsByCategory(String categoryId) {
		getEntity(12);
		return null;
	}

	public List<Product> getProductsBySearch(String... keywords) {
		// TODO Auto-generated method stub
		return null;
	}

	public int currentQtyInStock(String itemid) {
		// TODO Auto-generated method stub
		return 0;
	}

	public Item getItem(String itemId) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<Item> getItemsByProduct(String productId) {
		// TODO Auto-generated method stub
		return null;
	}

	public void takeStock(LineItem items) {
		// TODO Auto-generated method stub
		
	}

}
